<?php
class User {
    public $strategy = 'standart';
    public $isLogged;
    public $user_id;
    public $user_login;
    public $user_hash;
    public $user_ip;
    public $realname;
    public $phone;
    public $mail;
    public $bday;
    public $photo_small;
    public $photo_medium;
    public $photo_big;
    public $ownerof;
    public $model;
    public $aryObserversArray;

    function __construct() {
         $this->registry = Registry::getInstance();
        $lrmodel = new LRModel();

        $this->model = $lrmodel;
    }
    public function uploadAvatar($path, $user_id = false){
        $this->registry->load->library('class.Helper_User.php', 'user');
        $path_to_big = Helper_User::downloadAvatar($path, 250);
        if(!$path_to_big) return false;
        $path_to_small = Helper_User::downloadAvatar($path_to_big, 100);
        if(!$path_to_small) return false;
        $this->photo_small = $path_to_small;
        $this->photo_big = $path_to_big;
        return $this->model->updateProfile(array('avatar_big'=>$path_to_big, 'avatar_small'=>$path_to_small), ($user_id?$user_id:$this->user_id));
    }
    public function init($user)
    {
         foreach ($user as $key => $value) {
             $this->{$key} = $value;
         }
         if($this->is_online) $this->status = 'online'; else $this->status = 'offline';
         if(!$this->avatar_big) $this->avatar_big = DIR_IMAGES.'avatars/no_avatar.gif';
         if(!$this->avatar_small) $this->avatar_small = DIR_IMAGES.'avatars/no_avatar.gif';
    }
} 
?>
